/**
 * 角色详情对话框
 */
var TicketInfoDlg = {
    data: {
        pid: "",
        pName: ""
    }
};

layui.use(['layer', 'form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;

    // 让当前iframe弹层高度适应
    admin.iframeAuto();

    //初始化用户下拉框

    var ajax = new $ax(Feng.ctxPath + "/staffTicket/userData/" );
    var result = ajax.start();
    var list = result;    //返回的数据
    var server = document.getElementById("userData"); //server为select定义的id
    for(var p in list) {
        var option = document.createElement("option");  // 创建添加option属性
        option.setAttribute("value", p); // 给option的value添加值
        option.innerText = list[p];     // 打印option对应的纯文本
        server.appendChild(option);           //给select添加option子标签
        form.render("select");
    }

    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/staffTicket/dispatchSave", function (data) {
            Feng.success("派单成功!");

            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();
        }, function (data) {
            Feng.error("派单失败!" + data.responseJSON.message + "!");
        });
        ajax.set(data.field);
        ajax.start();
    });
});